home *** CD-ROM | disk | FTP | other *** search
- # Copyright (c) 1995 The Geometry Center; University of Minnesota
- # 1300 South Second Street; Minneapolis, MN 55454, USA;
- #
- # This file is part of geomview/OOGL. geomview/OOGL is free software;
- # you can redistribute it and/or modify it only under the terms given in
- # the file COPYING, which you should have received along with this file.
- # This and other related software may be obtained via anonymous ftp from
- # geom.umn.edu; email: software@geom.umn.edu.
-
- # Author: Timothy Rowley
-
-
- # set up nicer-looking gray colors
-
- catch { tk_bisque }
-
- #set tk_strictMotif 1
- #option add *Background gray70 userDefault
- #option add *Foreground gray20 userDefault
- #option add *Checkbutton.selector yellow userDefault
- #option add *Radiobutton.selector yellow userDefault
- #. configure -background gray70
-
-
- proc newColor {} {
- foreach p {r g b} {
- append color [format %02x [expr int([.crayola.c.$p.s get]*255.999)]]
- }
- .crayola.swatch configure -background "#$color"
- }
-
- proc setsliders {which abc} {
- foreach i {0 1 2} {
- set p [string range $which $i $i]
- set cmd [.crayola.c.$p.s cget -command]
- .crayola.c.$p.s configure -command {}
- .crayola.c.$p.s set [lindex $abc $i]
- if {$cmd != ""} {after idle .crayola.c.$p.s configure -command $cmd}
- }
- }
-
- proc newRGB {args} {
- crayolaSetColor [.crayola.c.r.s get] [.crayola.c.g.s get] [.crayola.c.b.s get]
- newColor
- }
-
- proc newHSV {args} {
- crayolaSetColor -hsv [.crayola.c.h.s get] [.crayola.c.s.s get] [.crayola.c.v.s get]
- newColor
- }
-
- proc mkCrayola {} {
- global operation
-
- toplevel .crayola
- set w .crayola
- wm title $w Crayola
- $w configure -borderwidth 2 -relief raised
-
- frame $w.col
- frame $w.s -borderwidth 3 -relief sunken
- frame $w.swatch -height 30
- frame $w.c
- foreach p {r g b h s v} {
- frame $w.c.$p
- label $w.c.$p.l -text [string toupper $p]
- if {[string match {[rgb]} $p]} {
- set cmd newRGB
- } else {
- set cmd newHSV
- }
- scale $w.c.$p.s -orient horizontal -from 0 -to 1 -resolution 0 -showvalue no -command $cmd
- pack $w.c.$p.l $w.c.$p.s -in $w.c.$p -side left -fill y
- pack $w.c.$p -side top
- }
- frame $w.c.gap
- pack $w.c.gap -after $w.c.b -pady 3
- pack $w.swatch -in $w.s -fill x
- pack $w.s $w.c -in $w.col -side top -expand 1 -fill x
-
- frame $w.buttons
- set b $w.buttons
- frame $b.bot
-
- set operation get
- radiobutton $b.b1 -text "Get" -value get -variable operation \
- -indicatoron false
- radiobutton $b.b2 -text "Set" -value set -variable operation \
- -indicatoron false
- radiobutton $b.b3 -text "Set all" -value setall -variable operation \
- -indicatoron false
- radiobutton $b.b4 -text "Eliminate Color" -value eliminate \
- -variable operation -indicatoron false
-
- button $b.b5 -text "Undo!" -command crayolaUndo
- button $b.b6 -text "Quit" -command crayolaQuit
- pack $b.b1 $b.b2 $b.b3 $b.b4 -fill x
- pack $b.b5 $b.b6 -in $b.bot -fill x
- pack $b.bot -expand 1 -fill x
-
- pack $w.col $w.buttons -side left -fill y -padx 2 -pady 2
- }
-
- wm withdraw .
- mkCrayola
- emodule_init crayola
-